<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org"
	xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<meta charset="utf-8">
<head >
<#include "/page/include.ftl">
</head>
<link href="${rc.contextPath}/static/ajax/libs/jquery-layout/jquery.layout-latest.css" rel="stylesheet"/>
<link href="${rc.contextPath}/static/ajax/libs/jquery-ztree/3.5/css/metro/zTreeStyle.css" rel="stylesheet"/>

<body class="gray-bg">
	<div class="container-div ui-layout-center">
		<div class="row">
			<div class="col-sm-12 search-collapse">
				<form id="formId">
					<div class="select-list">
						<ul>
							<li>
								任务名称：<input type="text" id="name"  name="name"/>
							</li>

							<li>
                                  资源路径：<input type="text" id="sourceType"  name="sourceType" />
                                          
							</li>

							<li>
                                文件名：<input  type="text" name="id" id="id" />
							</li>

							<li>
                                同步类型：<select id="syncType"  name="syncType">
                                           <option value="-1">请选择</option>
                                           <option value="1">全量</option>
                                           <option value="2">增量</option>
                                   </select>
							</li>

							<li>
								<a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
								<a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
							</li>
						</ul>
					</div>
				</form>
			</div>
			
	        <div class="btn-group-sm hidden-xs" id="toolbar" role="group">
	        	<a class="btn btn-success" onclick="$.operate.add()" >
	                <i class="fa fa-plus"></i> 新增
	            </a>
	           
	           
	        </div>
	        
	        <div class="col-sm-12 select-table table-striped">
			    <table id="bootstrap-table" data-mobile-responsive="true"></table>
			</div>
		</div>
	</div>
         
	<script src="${rc.contextPath}/static/ajax/libs/jquery-layout/jquery.layout-latest.js"></script>
	<script src="${rc.contextPath}/static/ajax/libs/jquery-ztree/3.5/js/jquery.ztree.all-3.5.js"></script>
	<script >
	    
		var editFlag = "";
		var removeFlag = "";
		var resetPwdFlag = "";
		var datas = "";
		var prefix = ctx + "ftp";
       
		$(function() {
			$('body').layout({ west__size: 185 });
			queryftpList();
		});
		var name = $("input[name='name']").val();
		var id = $("input[name='id']").val();
		var syncType = $("#syncType option:selected").val();
		var sourceType = $("input[name='sourceType']").val();


         function queryParams(params) {
           var search = $.table.queryParams(params);
               search.id = id;
               search.name = name;
               search.syncType = syncType;
               search.sourceType = sourceType;
           return search;
         }
		function queryftpList() {
		    var options = {
		        url: prefix + "/grid",
		        createUrl: prefix + "/add",
		        updateUrl: prefix + "/edit/{id}",
		        removeUrl: prefix + "/remove",
		        exportUrl: prefix + "/export",
		        pageNumber : 1, //初始化加载第一页
                pagination : true,//是否分页
               // sidePagination : 'client',//server:服务器端分页|client：前端分页
                pageSize : 10,//单页记录数
                striped:true,
		        modalName: "FTP客户端管理",
		        queryParams:queryParams,
		        search: false,
		        showExport: false,
		        columns: [
		        {
		            field: 'id',
		            title: '作业文件名'
		        },
		        {
		            field: 'syncType',
		            title: '文件同步类型',
		            formatter: function(value, row, index) {
		                var txt = "";
		                if(value == "1"){
		                  txt = "全量";
		                }else if(value == "2"){
		                   txt = "增量";
		                }
		                return txt;
		            }
		        }
		        ,
		        {
		            field: 'name',
		            title: '任务名称'
		        },
		        {
		            field: 'cronexpress',
		            title: '作业表达式'
		        },
		        {
		            field: 'table',
		            title: '目标库对应的表'
		        },
		        {
		            title: '操作',
		            align: 'center',
		            formatter: function(value, row, index) {
		                var actions = [];
		                
		                actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="$.operate.edit(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑</a> ');
		                actions.push('<a class="bbtn btn-danger btn-xs ' + editFlag + '" href="#" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-edit"></i>删除</a> ');
		                //actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="#" onclick="hander(\'' + row.id + '\')"><i class="fa fa-edit"></i>手动执行</a> ');
		               // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="#" onclick="startjob(\'' + row.id + '\')"><i class="fa fa-remove"></i>启动</a> ');
		                //actions.push('<a class="btn btn-info btn-xs ' + resetPwdFlag + '" href="#" onclick="stopjob(\'' + row.id + '\')"><i class="fa fa-key"></i>停止</a>');
		                return actions.join('');
		            }
		        }]
		    };
		    $.table.init(options);
		    
		}
		
		
		
		
		
		
		function startjob(id){
		   $.ajax({
        		cache : true,
        		type : "POST",
        		url : ctx + "ftp/start",
        		data : {
        			"id":id
        		},
        		async : false,
        		error : function(request) {
        		console.log(request);
        			$.modal.alertError("系统错误");
        		},
        		success : function(data) {
        		console.log(data);
        		$.modal.msgSuccess(data.msg);
        			//$.operate.successCallback(data);
        			$.table.refresh();
        		}
        	});
		}
		
		
		
		
		function hander(id){
		   $.ajax({
        		cache : true,
        		type : "POST",
        		url : ctx + "ftp/hander",
        		data : {
        			"id":id
        		},
        		async : false,
        		error : function(request) {
        		console.log(request);
        			$.modal.alertError("系统错误");
        		},
        		success : function(data) {
        		console.log(data);
        		$.modal.msgSuccess(data.msg);
        			//$.operate.successCallback(data);
        			$.table.refresh();
        		}
        	});
		}
		function stopjob(id){
		   $.ajax({
        		cache : true,
        		type : "POST",
        		url : ctx + "ftp/stop",
        		data : {
        			"id":id
        		},
        		async : false,
        		error : function(request) {
        			$.modal.alertError("系统错误");
        		},
        		success : function(data) {
        		console.log(data);
        		$.modal.msgSuccess(data.msg);
        		$.table.refresh();
        			//$.operate.successCallback(data);
        		}
        	});
		}
		
		

		
	</script>
</body>
</html>